package com.dudu.dladminserver.mapper;

import com.dudu.dladminserver.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 获取总记录数
     * @return
     */
//    @Select("select count(*) from user")
//    public Long count();

    /**
     * 获取分页数据
     * @param offset
     * @param pageSize
     * @return
     */
//    @Select("select * from user limit #{offset}, #{pageSize}")
//    public List<User> page(Integer offset, Integer pageSize);

//    @Select("select * from user")
    public List<User> page(String username, String phone, String nickname, Short status);

    /**
     * 批量删除
     * @param ids
     */
    void delete(List<Integer> ids);

    /**
     * 新增
     * @param user
     */
    @Insert("insert into user(username, password, phone, nickname, avatar, status, create_time, update_time) values (#{username}, #{password}, #{phone}, #{nickname}, #{avatar}, #{status}, #{createTime}, #{updateTime})")
    void add(User user);

    /**
     * 修改
     * @param user
     */
    void update(User user);

    /**
     * 详情
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getById(Integer id);

    /**
     * 根据用户名和密码查询
     * @param user
     * @return
     */
    @Select("select * from user where username = #{username} and password = #{password}")
    User getByIUsernameAndPassword(User user);
}
